# Copyright (C) Kumo inc. and its affiliates.
# Author: Jeff.li lijippy@163.com
# All rights reserved.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https:#www.gnu.org/licenses/>.
#
include_guard(GLOBAL)

pollux_set_source(gRPC)
pollux_resolve_dependency(gRPC CONFIG 1.48.1 REQUIRED)

set(POLLUX_GOOGLE_CLOUD_CPP_BUILD_VERSION 2.22.0)
set(POLLUX_GOOGLE_CLOUD_CPP_BUILD_SHA256_CHECKSUM
    0c68782e57959c82e0c81def805c01460a042c1aae0c2feee905acaa2a2dc9bf)
string(
  CONCAT POLLUX_GOOGLE_CLOUD_CPP_SOURCE_URL
         "https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/"
         "v${POLLUX_GOOGLE_CLOUD_CPP_BUILD_VERSION}.tar.gz")

pollux_resolve_dependency_url(GOOGLE_CLOUD_CPP)

message(STATUS "Building Google Cloud CPP storage from source")

FetchContent_Declare(
  google_cloud_cpp
  URL ${POLLUX_GOOGLE_CLOUD_CPP_SOURCE_URL}
  URL_HASH ${POLLUX_GOOGLE_CLOUD_CPP_BUILD_SHA256_CHECKSUM}
  OVERRIDE_FIND_PACKAGE EXCLUDE_FROM_ALL SYSTEM)

set(GOOGLE_CLOUD_CPP_ENABLE_EXAMPLES OFF)
set(GOOGLE_CLOUD_CPP_ENABLE
    "storage"
    CACHE STRING "The list of libraries to build.")
FetchContent_MakeAvailable(google_cloud_cpp)
